package com.biz.user.controller;

import com.biz.redis.util.*;
import lombok.extern.slf4j.*;
import org.apache.rocketmq.spring.core.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;

/**
 * @Description
 * @Author liuxi
 * @Date 2024/4/17
 **/
@RestController
@Slf4j
public class TestController {

    @Autowired
    private RedisUtil redisUtil;

    @Autowired
    private CacheUtil cacheUtil;

    @Autowired
    private RedisShareLockUtil redisShareLockUtil;

    @Autowired
    private RocketMQTemplate rocketMQTemplate;
    
    @GetMapping("/test")
    public String test() {
        return "Hello World";
    }

    @GetMapping("/testRedis")
    public void testRedis() {
        redisUtil.set("name", "lxy");
        redisUtil.get("name");
    }

    @GetMapping("/testRedisLock")
    public void testRedisLock() {
        boolean result = redisShareLockUtil.lock("ccc", "1234567898", 100000L);
        System.out.println(result);
    }

    @GetMapping("/testLog")
    public void testLog() {
        long start = System.currentTimeMillis();
        for (int i = 0; i < 100000; i++) {
            log.info("这是{}条日志", i);
        }
        long end = System.currentTimeMillis();
        log.info("当前耗时:{}", end - start);
    }

    @GetMapping("/testLocalCache")
    public void testLocalCache() {
        // list<Long> skuId
        // 价格优惠卷
        // Map<Long, SKUINFO>
        // 反射

    }

    @PostMapping("/pushMessage")
    public void testpushMessage() {
        int id = 123;
        rocketMQTemplate.convertAndSend("first-topic", "早上好" + id);
    }
}
